<%-- 
    Document   : listdb
    Created on : 2014/2/24, 下午 03:56:29
    Author     : Gjun
--%>

<%@page import="java.sql.DriverManager"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        java.sql.Connection con = DriverManager.getConnection("jdbc:sqlserver://10.10.3.14:1433;databaseName=javadb", "javadb", "java");
        java.sql.Statement st = con.createStatement();
        
        String sql="SELECT * FROM 產品維護";
        java.sql.ResultSet rs = st.executeQuery(sql);
        
    %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h2>產品清單</h2>
        <table border="2">
                 <tr><td>id</td><td>產品名稱</td><td>產品價格</td><td>庫存量</td><td>產品介紹</td></tr>
        <%
        while(rs.next())
        {
            String id = rs.getString("id");
            String 產品名稱 = rs.getString("產品名稱");
            String 產品價格 = rs.getString("產品價格");
            String 庫存量 = rs.getString("庫存量");
            String 產品介紹 = rs.getString("產品介紹");            
            out.print("<tr><td>"+id+"</td><td>"+產品名稱+"</td><td>"+產品價格+"</td><td>"+庫存量+"</td><td>"+產品介紹+"</td>");
            out.print("<td><a href='commupdate.jsp?id="+id+"'>更新</a></td></tr>");
        }
        
        rs.close();
        st.close();
        con.close();        
        %>
        
        
        </table>
        <form action="comminsert.jsp">
            <input type="submit" value="新增">
        </form>
        <form action="home.jsp">
            <input type="submit" value="回管理首頁">
        </form>
    </body>
</html>
